package cz.idsv.web.mvc.model.service;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.security.access.annotation.Secured;
import org.springframework.stereotype.Service;

import cz.idsv.web.mvc.model.dao.AddressDao;
import cz.idsv.web.mvc.model.entity.AddressEntity;


@Service("AddressService")
public class AddressServiceImpl implements AddressService {

	@Autowired()
	private AddressDao addressDao;
	
	
	public Collection<AddressEntity> findAddress() throws DataAccessException{
		return addressDao.findAddress();
	}

	public void save( AddressEntity  addressEntity) {
		 addressDao.save(addressEntity);
	}

	@Secured ({"ROLE_ADMIN"})
	public void delete( AddressEntity  addressEntity) {
		 addressDao.delete( addressEntity);
	}

	public  AddressEntity findAddressById(Integer id)
			throws DataAccessException {
		return  addressDao.findAddressById(id);
	}

	public Collection<AddressEntity> findAddressByCity(String city)
			throws DataAccessException {
		return  addressDao.findAddressByCity(city);
	}

	public Collection<AddressEntity> findAddressByStreet(String street)
			throws DataAccessException {
		return  addressDao.findAddressByStreet(street);
	}

	public Collection<AddressEntity> findAddressByStreetNumber(Integer streetNumber)
			throws DataAccessException {
		return  addressDao.findAddressByStreetNumber(streetNumber);
	}

	public Collection<AddressEntity> findAddressByPostNumber(Integer postNumber)
			throws DataAccessException {
		return  addressDao.findAddressByPostNumber(postNumber);
	}


}
	